<?php

namespace App\Remote\FuYou;

use App\Exceptions\BaseException;
use App\Kuafu\Pay\Channel\FuYou\FuYouBase;
use GuzzleHttp\Exception\GuzzleException;
use Symfony\Component\HttpFoundation\Request as RequestAlias;

class FuYouFundsTransferRemote extends Remote
{

    /**
     * 资金划拨查询
     *
     * @param string $fyMerchantId
     * @param string $startDate
     * @param string $endDate
     * @param int $startIndex
     * @param int $endIndex
     * @return mixed
     * @throws BaseException
     * @throws GuzzleException
     */
    public static function queryChnlPayAmt(
        string $fyMerchantId,
        string $startDate,
        string $endDate,
        int $startIndex,
        int $endIndex
    ) {
        $params         = [
            "ins_cd"      => self::getInsCd(),
            "mchnt_cd"    => $fyMerchantId,
            "random_str"  => FuYouBase::createRandomStr(),
            "start_date"  => $startDate,
            "end_date"    => $endDate,
            "start_index" => $startIndex,
            "end_index"   => $endIndex
        ];
        $params['sign'] = self::getSign($params);
        $postDataXml    = self::toXml($params);

        return self::customRequestV2(
            "queryChnlPayAmt",
            RequestAlias::METHOD_POST,
            ['form_params' => ['req' => urlencode($postDataXml)]]
        );
    }

}
